package tables

import (
	"peilian-api/app/global/variable"
)

type YzItems struct { //开始结束视频
	Model
	Bid    string `json:"bid" gorm:"type:varchar(64);not null;default:\"\";comment:此次交易id"`
	Oid    string `json:"oid" gorm:"type:varchar(64);not null;default:\"\";comment:订单明细id"`
	ItemId int64  `json:"item_id" gorm:"type:bigint(20);unsigned;not null;default:0;comment:商品id"`
	Num    int    `json:"num" gorm:"ype:int(11);unsigned;not null;default:0;comment:商品数量"`
	Title  string `json:"title" gorm:"type:varchar(256);not null;default:\"\";comment:商品名称"`
	Alais  string `json:"alias" gorm:"type:varchar(64);not null;default:\"\";comment:商品别称"`
	Price  string `json:"price" gorm:"type:varchar(64);not null;default:\"\";comment:商品价格"`
}

func (o *YzItems) TableName() string {
	return "yz_items"
}

// 创建交易
func (*YzItems) CreateItems(yzItems YzItems) uint {
	d := variable.DB.MySQL.Create(&yzItems)
	if d.RowsAffected == 0 {
		return 0
	}
	return yzItems.ID
}

// 获取商品信息
func (*YzItems) GetItems(ids []int) []YzItems {
	var items []YzItems
	variable.DB.MySQL.Where("id in (?)", ids).Find(&items)
	return items
}
